#!/usr/bin/python3
# -*- coding: utf-8 -*-

import os
from pathlib import Path

class Config:
    """基础配置类"""
    # 应用配置
    SECRET_KEY = os.environ.get('SECRET_KEY') or 'hard-to-guess-string'
    DEBUG = False
    TESTING = False
    
    # 服务器配置
    HOST = os.environ.get('HOST') or '0.0.0.0'
    PORT = int(os.environ.get('PORT') or 5001)
    
    # 数据库配置
    DB_PATH = os.environ.get('DB_PATH') or 'freyr_mock.db'
    
    # Redis配置
    REDIS_HOST = os.environ.get('REDIS_HOST') or '45.205.31.46'
    REDIS_PORT = int(os.environ.get('REDIS_PORT') or 6379)
    REDIS_PASSWORD = os.environ.get('REDIS_PASSWORD') or 'BEvtpzcZ3CXzNV4djpxX'
    
    # ID生成器配置
    ID_GENERATOR_TYPE = os.environ.get('ID_GENERATOR_TYPE') or 'uuid'  # 'snowflake' 或 'uuid'
    ID_PREFIX = os.environ.get('ID_PREFIX') or None  # UUID前缀，仅在使用uuid时有效
    WORKER_ID = int(os.environ.get('WORKER_ID') or 1)  # 雪花算法工作机器ID
    DATACENTER_ID = int(os.environ.get('DATACENTER_ID') or 1)  # 雪花算法数据中心ID
    
    @staticmethod
    def init_app(app):
        """初始化应用配置"""
        pass

class DevelopmentConfig(Config):
    """开发环境配置"""
    DEBUG = True
    
class TestingConfig(Config):
    """测试环境配置"""
    TESTING = True
    DB_PATH = 'freyr_mock_test.db'
    
class ProductionConfig(Config):
    """生产环境配置"""
    pass

# 配置映射字典
config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}
